using System;
using System.Xml;

namespace Mbs.CastleContainer
{
    class DefineElementProcessor : AbstractXmlNodeProcessor
    {
        private static readonly String FlagAttrName = "flag";

        public DefineElementProcessor()
        {
        }

        public override String Name
        {
            get { return "define"; }
        }

        public override void Process(IXmlProcessorNodeList nodeList, IXmlProcessorEngine engine)
        {
            XmlElement element = nodeList.Current as XmlElement;

            String flag = GetRequiredAttribute(element, FlagAttrName);

            Process(flag, engine);
            RemoveItSelf(element);
        }

        protected virtual void Process(string flag, IXmlProcessorEngine engine)
        {
            engine.AddFlag(flag);
        }
    }
}
